/*
** 2509.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Thu Sep 25 19:15:18 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "2509.h" */
#include <stdio.h>

int main()
{
     int t, ft, reroll, remain;

     while(scanf("%d%d", &t, &reroll) != EOF){
	  ft = t;
	  while(t / reroll){
	       remain = t % reroll;
	       t /= reroll;
	       ft += t;
	       t += remain;
	  }
	  printf("%d\n", ft);
     }
     return 0;
}

	       
